﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ChinaDynastyTours.Helpers;
using DevExpress.XtraBars;
using System.Threading;
using System.Configuration;
using ChinaDynastyTours.Controls;
using System.Web.Security;
using ChinaDynastyTours.Views.FinanceGroup;

namespace ChinaDynastyTours.Views
{
    public partial class MainForm : DevExpress.XtraEditors.XtraForm
    {
        string skinMask = "Skin:";

        //空闲时间打开控制台
        void Application_Idle(object sender, EventArgs e)
        {
            if (_bStartConsole)
            {
                Application.Idle -= new EventHandler(Application_Idle);
                ConsoleButtonItem.PerformClick();
                ConsoleButtonItem.Enabled = true;
            }
        }
        public MainForm()
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            string themeName = ConfigurationManager.AppSettings["Themes"];

            this.Visible = false;
            foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
            {
                BarButtonItem item = new BarButtonItem(MainBarManager, skinMask + cnt.SkinName);
                iPaintStyle.AddItem(item);
                item.ItemClick += new ItemClickEventHandler(OnSkinClick);
            }
            //显式设定的Theme
            foreach (BarItemLink item in iPaintStyle.ItemLinks)
                if (item.Caption == (skinMask + themeName))
                    DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(themeName);

            iPaintStyle.Caption = skinMask + MainLookAndFeel.LookAndFeel.ActiveLookAndFeel.SkinName;
        }
        void OnSkinClick(object sender, ItemClickEventArgs e)
        {
            string skinName = e.Item.Caption.Replace(skinMask, "");
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skinName);
            MainBarManager.GetController().PaintStyleName = "Skin";
            iPaintStyle.Caption = e.Item.Caption;
            iPaintStyle.Hint = iPaintStyle.Caption;
            iPaintStyle.ImageIndex = -1;

            //保存设定
            //ConfigurationManager.AppSettings.Set("Themes",skinName);
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings["Themes"].Value = skinName;
            config.Save(ConfigurationSaveMode.Modified);
        }
        private void ChangePwdButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChangePasswordForm uw = new ChangePasswordForm(Thread.CurrentPrincipal.Identity.Name, new SecurityHelper());
            if (DialogResult.OK == uw.ShowDialog(this))
            {
                MessageBox.Show("此用户信息修改成功", "信息提示", MessageBoxButtons.OK);
            }
        }

        private void ConsoleButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "NotifyForm")
                {
                    form.Activate();
                    return;
                }
            }
            NotifyForm notifyForm = new NotifyForm();
            notifyForm.MdiParent = this;
            notifyForm.Show();

            //ConsoleForm consoleForm = new ConsoleForm();
            //consoleForm.MdiParent = this;
            //consoleForm.Show(); 
        }

        private void AboutButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            new AboutBox().ShowDialog(this);
        }

        private void ExitButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (MessageBox.Show("确定退出系统吗？", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                Application.Exit();
        }

        #region 组团管理
        private void TeamBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "TeamGroupForm")
                {
                    form.Activate();
                    return;
                }
            }
            TeamGroupForm teamgroupForm = new TeamGroupForm();
            teamgroupForm.MdiParent = this;
            teamgroupForm.Show();

        }
        private void TeamLookUpBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "LookupTeamGroupForm")
                {
                    form.Activate();
                    return;
                }
            }
            LookupTeamGroupForm lookupTeamGroupForm = new LookupTeamGroupForm();
            lookupTeamGroupForm.MdiParent = this;
            lookupTeamGroupForm.Show();
        }

        #endregion

        private void BatchHotelOrderBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchHotelOrdersForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchHotelOrdersForm batchhotelorderForm = new BatchHotelOrdersForm();
            batchhotelorderForm.MdiParent = this;
            batchhotelorderForm.Show();
        }

        private void TrainFlightBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchTrainFlightOrderForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchTrainFlightOrderForm trainFlightOrderForm = new BatchTrainFlightOrderForm();
            trainFlightOrderForm.MdiParent = this;
            trainFlightOrderForm.Show();
        }

        private void LocalTeamGroupScheduleBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "LocalTeamGroupForm")
                {
                    form.Activate();
                    return;
                }
            }
            LocalTeamGroupForm localTeamGroupForm = new LocalTeamGroupForm();
            localTeamGroupForm.MdiParent = this;
            localTeamGroupForm.Show();
        }

        private void VehicleBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchVehicleOrderForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchVehicleOrderForm vehicleOrderForm = new BatchVehicleOrderForm();
            vehicleOrderForm.MdiParent = this;
            vehicleOrderForm.Show();
        }

        private void EntertainmentRestaurantBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchEntertainmenRestaurantOrderForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchEntertainmenRestaurantOrderForm entertainmentRestaurantOrderForm = new BatchEntertainmenRestaurantOrderForm();
            entertainmentRestaurantOrderForm.MdiParent = this;
            entertainmentRestaurantOrderForm.Show();
        }

        private void SecurityBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            new UserAndRolesForm(new SecurityHelper()).ShowDialog(this);
        }

        private bool _bStartConsole;//是否启动控制台
        private void MainForm_Load(object sender, EventArgs e)
        {
            #region 汉化
            //DevExpress.Accessibility.AccLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressUtilsLocalizationCHS();
            //DevExpress.XtraBars.Localization.BarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraBarsLocalizationCHS();
            //DevExpress.XtraCharts.Localization.ChartLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraChartsLocalizationCHS();
            //DevExpress.XtraEditors.Controls.Localizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraEditorsLocalizationCHS();
            //DevExpress.XtraGrid.Localization.GridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraGridLocalizationCHS();
            //DevExpress.XtraLayout.Localization.LayoutLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraLayoutLocalizationCHS();
            //DevExpress.XtraNavBar.NavBarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraNavBarLocalizationCHS();
            ////DevExpress.XtraPivotGrid.Localization.PivotGridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraPivotGridLocalizationCHS();
            //DevExpress.XtraPrinting.Localization.PreviewLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraPrintingLocalizationCHS();
            //DevExpress.XtraReports.Localization.ReportLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraReportsLocalizationCHS();
            //DevExpress.XtraRichEdit.Localization.XtraRichEditLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraRichEditLocalizationCHS();
            //DevExpress.XtraRichEdit.Localization.RichEditExtensionsLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraRichEditExtensionsLocalizationCHS();
            //DevExpress.XtraScheduler.Localization.SchedulerResLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerLocalizationCHS();
            //DevExpress.XtraScheduler.Localization.SchedulerExtensionsResLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerExtensionsLocalizationCHS();
            //DevExpress.XtraScheduler.Localization.SchedulerLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerLocalizationCHS();
            //DevExpress.XtraScheduler.Localization.SchedulerExtensionsLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerExtensionsLocalizationCHS();
            //DevExpress.XtraSpellChecker.Localization.SpellCheckerLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSpellCheckerLocalizationCHS();
            ////DevExpress.XtraTreeList.Localization.TreeListLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraTreeListLocalizationCHS();
            ////DevExpress.XtraVerticalGrid.Localization.VGridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraVerticalGridLocalizationCHS();
            ////DevExpress.XtraWizard.Localization.WizardLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraWizardLocalizationCHS();

            #endregion

            if (DialogResult.OK == new LoginWindow(new SecurityHelper()).ShowDialog(this))
            {
                this.Visible = true;
                this.WindowState = FormWindowState.Maximized;

                MainBarManager.Bars[1].ItemLinks[1].Caption = UserInfoCtrl.GetNameByUserName(Thread.CurrentPrincipal.Identity.Name);
                switch (ApplicationHelper.RankID)//否则根据当前登录用户级别进行显示
                {
                    case 0://总经理 级别
                        MainBarManager.Bars[1].ItemLinks[2].Caption = "总经理级别";
                        break;
                    case 1://部门经理 级别
                        MainBarManager.Bars[1].ItemLinks[2].Caption = "部门经理级别";
                        break;
                    case 2://普通员工 级别
                        MainBarManager.Bars[1].ItemLinks[2].Caption = "普通员工级别";
                        break;
                    default: break;
                }

                if (Thread.CurrentPrincipal.Identity.IsAuthenticated == true)
                {
                    if (Thread.CurrentPrincipal.IsInRole("导游") == true)
                    {
                        GuideAccountGroup.Visible = true;
                        LeftNavBar.ActiveGroup = GuideAccountGroup;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("领导") == true)
                    {
                        StatisticsGroup.Visible = true;
                        LeftNavBar.ActiveGroup = StatisticsGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("财务") == true)
                    {
                        FinanceGroup.Visible = true;
                        LeftNavBar.ActiveGroup = FinanceGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("导游管理") == true)
                    {
                        GuideGroup.Visible = true;
                        LeftNavBar.ActiveGroup = GuideGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("评价录入") == true)
                    {
                        EvaluateGroup.Visible = true;
                        LeftNavBar.ActiveGroup = GuideGroup;

                        _bStartConsole = true;
                    }
                    //if (Thread.CurrentPrincipal.IsInRole("基础信息管理员") == true)
                    //{
                    //    BaseInfoGroup.Visible = true;
                    //    LeftNavBar.ActiveGroup = BaseInfoGroup;

                    //    _bStartConsole = true;
                    //    //ConsoleButtonItem.PerformClick();
                    //    //ConsoleButtonItem.Enabled = true;
                    //}

                    if (Thread.CurrentPrincipal.IsInRole("操作") == true)
                    {
                        TeamGroup.Visible = true;
                        BaseInfoGroup.Visible = true;
                        SystemGroup.Visible = true;

                        EMailBarItem.Visible = true;
                        SecurityBarItem.Visible = false;
                        SysParameterBarItem.Visible = false;
                        DepartmentBarItem.Visible = false;

                        LeftNavBar.ActiveGroup = TeamGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("火车飞机") == true)
                    {
                        ScheduleGroup.Visible = true;
                        TrainFlightBarItem.Visible = true;
                        LeftNavBar.ActiveGroup = ScheduleGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("本地接待") == true)
                    {
                        ScheduleGroup.Visible = true;
                        LocalTeamGroupScheduleBarItem.Visible = true;
                        VehicleBarItem.Visible = true;
                        EntertainmentRestaurantBarItem.Visible = true;
                        LeftNavBar.ActiveGroup = ScheduleGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }

                    if (Thread.CurrentPrincipal.Identity.Name.ToLower() == "admin" || Thread.CurrentPrincipal.IsInRole("系统管理员"))
                    {
                        GuideAccountGroup.Visible = true;
                        TeamGroup.Visible = true;
                        ScheduleGroup.Visible = true;
                        //ScheduleGroup组下的三项
                        {
                            LocalTeamGroupScheduleBarItem.Visible = true;
                            TrainFlightBarItem.Visible = true;
                            VehicleBarItem.Visible = true;
                            EntertainmentRestaurantBarItem.Visible = true;
                        }

                        FinanceGroup.Visible = true;
                        GuideGroup.Visible = true;
                        BaseInfoGroup.Visible = true;
                        StatisticsGroup.Visible = true;
                        ShopManageGroup.Visible = true;
                        SystemGroup.Visible = true;

                        EMailBarItem.Visible = true;
                        SecurityBarItem.Visible = true;
                        SysParameterBarItem.Visible = true;
                        DepartmentBarItem.Visible = true;

                        LeftNavBar.ActiveGroup = TeamGroup;

                        _bStartConsole = true;
                        //ConsoleButtonItem.PerformClick();
                        //ConsoleButtonItem.Enabled = true;
                    }
                    if (Thread.CurrentPrincipal.IsInRole("商店管理") == true)
                    {
                        ShopManageGroup.Visible = true;
                        LeftNavBar.ActiveGroup = ShopManageGroup;
                    }
                }
            }
            else
                this.Close();
        }

        private void PayApplyBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "PayApplyForm")
                {
                    form.Activate();
                    return;
                }
            }
            PayApplyForm payApplyForm = new PayApplyForm();
            payApplyForm.MdiParent = this;
            payApplyForm.Show();
        }

        private void PayApplyConfirmBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "PaymentConfirmForm")
                {
                    form.Activate();
                    return;
                }
            }
            PaymentConfirmForm paymentConfirmForm = new PaymentConfirmForm();
            paymentConfirmForm.MdiParent = this;
            paymentConfirmForm.Show();
        }
        private void MonthManagerBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "MonthPaymentForm")
                {
                    form.Activate();
                    return;
                }
            }
            MonthPaymentForm monthForm = new MonthPaymentForm();
            monthForm.MdiParent = this;
            monthForm.Show();

        }
        private void IncomeBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "IncomeForm")
                {
                    form.Activate();
                    return;
                }
            }
            IncomeForm incomeForm = new IncomeForm();
            incomeForm.MdiParent = this;
            incomeForm.Show();
        }
        private void CashApplyConfirmBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CashApplyGuideForm")
                {
                    form.Activate();
                    return;
                }
            }
            CashApplyGuideForm cashApplyGuideForm = new CashApplyGuideForm();
            cashApplyGuideForm.MdiParent = this;
            cashApplyGuideForm.Show();
        }
        private void FinanceSettlementBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "FinanceSettlementForm")
                {
                    form.Activate();
                    return;
                }
            }
            FinanceSettlementForm finSettlementForm = new FinanceSettlementForm();
            finSettlementForm.MdiParent = this;
            finSettlementForm.Show();
        }

        private void BatchPayBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchPayForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchPayForm batchPayForm = new BatchPayForm();
            batchPayForm.MdiParent = this;
            batchPayForm.Show();
        }

        private void BatchPayPrintBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BatchPayPrintForm")
                {
                    form.Activate();
                    return;
                }
            }
            BatchPayPrintForm batchPayPrintForm = new BatchPayPrintForm();
            batchPayPrintForm.MdiParent = this;
            batchPayPrintForm.Show();
        }

        private void GuideStatusBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideStatusForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideStatusForm guideStatusForm = new GuideStatusForm();
            guideStatusForm.MdiParent = this;
            guideStatusForm.Show();
        }

        private void GuidNotifiedBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideNotifiedForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideNotifiedForm guideNofiedForm = new GuideNotifiedForm();
            guideNofiedForm.MdiParent = this;
            guideNofiedForm.Show();
        }

        private void GuidBaseInfoBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideManagerForm guideManagerForm = new GuideManagerForm();
            guideManagerForm.MdiParent = this;
            guideManagerForm.Show();
        }

        private void CityBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CityManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            CityManagerForm cityfrm = new CityManagerForm();
            cityfrm.MdiParent = this;
            cityfrm.Show();
        }

        private void CountryBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CountryManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            CountryManagerForm countryForm = new CountryManagerForm();
            countryForm.MdiParent = this;
            countryForm.Show();
        }

        private void CustomerBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CustomerManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            CustomerManagerForm customerForm = new CustomerManagerForm();
            customerForm.MdiParent = this;
            customerForm.Show();
        }


        private void FlightBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "FlightManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            FlightManagerForm flightForm = new FlightManagerForm();
            flightForm.MdiParent = this;
            flightForm.Show();
        }

        private void TrainBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "TrainManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            TrainManagerForm trainForm = new TrainManagerForm();
            trainForm.MdiParent = this;
            trainForm.Show();
        }

        private void ProviderBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ProviderManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            ProviderManagerForm providerForm = new ProviderManagerForm();
            providerForm.MdiParent = this;
            providerForm.Show();
        }

        private void VehicleServiceBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "VehicleServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            VehicleServiceForm vehicleServiceForm = new VehicleServiceForm();
            vehicleServiceForm.MdiParent = this;
            vehicleServiceForm.Show();
        }

        private void RestaurantBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "RestaurantServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            RestaurantServiceForm resturantServiceForm = new RestaurantServiceForm();
            resturantServiceForm.MdiParent = this;
            resturantServiceForm.Show();
        }

        private void PlayTicketBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "PlayTicketServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            PlayTicketServiceForm playTicketServiceForm = new PlayTicketServiceForm();
            playTicketServiceForm.MdiParent = this;
            playTicketServiceForm.Show();
        }

        private void HotelBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "HotelServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            HotelServiceForm hotelServiceForm = new HotelServiceForm();
            hotelServiceForm.MdiParent = this;
            hotelServiceForm.Show();
        }

        private void TravelAgentBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "TravelAgentServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            TravelAgentServiceForm travelAgenServiceForm = new TravelAgentServiceForm();
            travelAgenServiceForm.MdiParent = this;
            travelAgenServiceForm.Show();
        }

        private void ParkTicketBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ParkTicketServiceForm")
                {
                    form.Activate();
                    return;
                }
            }
            ParkTicketServiceForm parkTicketServiceForm = new ParkTicketServiceForm();
            parkTicketServiceForm.MdiParent = this;
            parkTicketServiceForm.Show();
        }

        private void SignBillAccountBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "SignBillAccountForm")
                {
                    form.Activate();
                    return;
                }
            }
            SignBillAccountForm signBillAccountForm = new SignBillAccountForm();
            signBillAccountForm.MdiParent = this;
            signBillAccountForm.Show();
        }

        private void CashAccountBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CashAccountForm")
                {
                    form.Activate();
                    return;
                }
            }
            CashAccountForm cashAccountForm = new CashAccountForm();
            cashAccountForm.MdiParent = this;
            cashAccountForm.Show();
        }

        private void CheckAccountBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CheckAccountForm")
                {
                    form.Activate();
                    return;
                }
            }
            CheckAccountForm checkAccountForm = new CheckAccountForm();
            checkAccountForm.MdiParent = this;
            checkAccountForm.Show();
        }

        private void ServiceEvaluationBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //foreach (Form form in Application.OpenForms)
            //{
            //    if (form.Name == "ServiceEvaluationForm")
            //    {
            //        form.Activate();
            //        return;
            //    }
            //}
            //TravelEvaluationForm serviceEvluationForm = new TravelEvaluationForm();
            //serviceEvluationForm.MdiParent = this;
            //serviceEvluationForm.Show();
        }

        private void GuideServiceEvaluationBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //foreach (Form form in Application.OpenForms)
            //{
            //    if (form.Name == "GuideEvaluationForm")
            //    {
            //        form.Activate();
            //        return;
            //    }
            //}
            //GuideEvaluationAnalysisForm guideEvluationForm = new GuideEvaluationAnalysisForm();
            //guideEvluationForm.MdiParent = this;
            //guideEvluationForm.Show();
        }


        private void HotelServiceEvaluationBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //foreach (Form form in Application.OpenForms)
            //{
            //    if (form.Name == "HotelEvaluationForm")
            //    {
            //        form.Activate();
            //        return;
            //    }
            //}
            //HotelEvaluationAnalysisForm hotelEvaluationForm = new HotelEvaluationAnalysisForm();
            //hotelEvaluationForm.MdiParent = this;
            //hotelEvaluationForm.Show();
        }

        private void TourgroupProviderEvaluationBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //foreach (Form form in Application.OpenForms)
            //{
            //    if (form.Name == "ProviderEvaluationForm")
            //    {
            //        form.Activate();
            //        return;
            //    }
            //}
            //ProviderEvaluationForm providerEvaluationForm = new ProviderEvaluationForm();
            //providerEvaluationForm.MdiParent = this;
            //providerEvaluationForm.Show();

        }

        private void SysParameterBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            SysParameterForm sysParamForm = new SysParameterForm();
            sysParamForm.ShowDialog(this);
        }

        private void CustomerAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CustomerAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            CustomerAnalysisForm customerAnalysisForm = new CustomerAnalysisForm();
            customerAnalysisForm.MdiParent = this;
            customerAnalysisForm.Show();
        }
        private void CountryAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CountryAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            CountryAnalysisForm country = new CountryAnalysisForm();
            country.MdiParent = this;
            country.Show();
        }

        private void SaleAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "SaleAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            SaleAnalysisForm SaleAnalysisForm = new SaleAnalysisForm();
            SaleAnalysisForm.MdiParent = this;
            SaleAnalysisForm.Show();

        }

        private void TourgroupAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "TourgroupAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            TourgroupAnalysisForm tourgroupAnalysisForm = new TourgroupAnalysisForm();
            tourgroupAnalysisForm.MdiParent = this;
            tourgroupAnalysisForm.Show();

        }

        private void ProviderAnalysBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ProviderAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            ProviderAnalysisForm providerAnalysisForm = new ProviderAnalysisForm();
            providerAnalysisForm.MdiParent = this;
            providerAnalysisForm.Show();
        }

        private void FinanceReportBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            new FinanceReportFinalForm().ShowDialog(this);
        }

        private void ExpenseTypeBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ExpenseTypeForm")
                {
                    form.Activate();
                    return;
                }
            }
            ExpenseTypeForm expenseTypeForm = new ExpenseTypeForm();
            expenseTypeForm.MdiParent = this;
            expenseTypeForm.Show();
        }

        private void AccountManagerBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "AccountManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            AccountManagerForm accountManagerForm = new AccountManagerForm();
            accountManagerForm.MdiParent = this;
            accountManagerForm.Show();
        }

        private void DepartmentBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "DepmentManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            DepmentManagerForm depmentManagerForm = new DepmentManagerForm();
            depmentManagerForm.MdiParent = this;
            depmentManagerForm.Show();
        }

        private void EMailBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "LogForm")
                {
                    form.Activate();
                    return;
                }
            }
            LogForm logForm = new LogForm();
            logForm.MdiParent = this;
            logForm.Show();
        }

        private void CommissionItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CommissionEditorForm")
                {
                    form.Activate();
                    return;
                }
            }
            CommissionEditorForm commForm = new CommissionEditorForm();
            commForm.MdiParent = this;
            commForm.Show();
        }

        private void CommissionFinanceItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CommissionFinanceVerifyForm")
                {
                    form.Activate();
                    return;
                }
            }
            CommissionFinanceVerifyForm commFVerifyForm = new CommissionFinanceVerifyForm();
            commFVerifyForm.MdiParent = this;
            commFVerifyForm.Show();
        }

        private void ShopManagerItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ShopManagerForm")
                {
                    form.Activate();
                    return;
                }
            }
            ShopManagerForm shopForm = new ShopManagerForm();
            shopForm.MdiParent = this;
            shopForm.Show();
        }

        private void DisperseAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "DisperseAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            DisperseAnalysisForm disperseForm = new DisperseAnalysisForm();
            disperseForm.MdiParent = this;
            disperseForm.Show();
        }

        private void BusinessADRAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "BusinessADRAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            BusinessADRAnalysisForm businessForm = new BusinessADRAnalysisForm();
            businessForm.MdiParent = this;
            businessForm.Show();
        }

        private void SaleSingleAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "SaleSingleAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            SaleSingleAnalysisForm saleForm = new SaleSingleAnalysisForm();
            saleForm.MdiParent = this;
            saleForm.Show();
        }

        private void ProviderBusinessProportionAnalysBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ProviderBusinessProportionAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            ProviderBusinessProportionAnalysisForm providerForm = new ProviderBusinessProportionAnalysisForm();
            providerForm.MdiParent = this;
            providerForm.Show();
        }

        private void ProviderYearAnalysBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ProviderYearAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            ProviderYearAnalysisForm providerForm = new ProviderYearAnalysisForm();
            providerForm.MdiParent = this;
            providerForm.Show();
        }

        private void ProviderDisperseAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ProviderDisperseAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            ProviderDisperseAnalysisForm providerForm = new ProviderDisperseAnalysisForm();
            providerForm.MdiParent = this;
            providerForm.Show();
        }

        private void GuideAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideAnalysisForm guideForm = new GuideAnalysisForm();
            guideForm.MdiParent = this;
            guideForm.Show();
        }

        private void PlanePriceAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "PlanePriceAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            PlanePriceAnalysisForm planeForm = new PlanePriceAnalysisForm();
            planeForm.MdiParent = this;
            planeForm.Show();
        }

        private void TravelGuideManagerBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideManagerForClientForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideManagerForTravelForm guideManager = new GuideManagerForTravelForm();
            guideManager.MdiParent = this;
            guideManager.Show();
        }

        private void HotelEvaluatenavBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "HotelEvaluateForm")
                {
                    form.Activate();
                    return;
                }
            }
            HotelEvaluateForm hotelEvaluateForm = new HotelEvaluateForm("");
            hotelEvaluateForm.MdiParent = this;
            hotelEvaluateForm.Show();
        }

        private void GuideEvaluateBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideEvaluateForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideEvaluateForm guideEvaluateForm = new GuideEvaluateForm("");
            guideEvaluateForm.MdiParent = this;
            guideEvaluateForm.Show();
        }

        private void RestaurantEvaluateBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "RestaurantEvaluateForm")
                {
                    form.Activate();
                    return;
                }
            }
            RestaurantEvaluateForm restaurantEvaluateForm = new RestaurantEvaluateForm("");
            restaurantEvaluateForm.MdiParent = this;
            restaurantEvaluateForm.Show();
        }

        private void VehicleEvaluateBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "VehicleEvaluateForm")
                {
                    form.Activate();
                    return;
                }
            }
            VehicleEvaluateForm hotelEvaluateForm = new VehicleEvaluateForm("");
            hotelEvaluateForm.MdiParent = this;
            hotelEvaluateForm.Show();
        }

        private void HotelEvaluateAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "HotelEvaluateAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            HotelEvaluateAnalysisForm hote = new HotelEvaluateAnalysisForm();
            hote.MdiParent = this;
            hote.Show();
        }

        private void GuideEvaluateAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideEvaluateAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideEvaluateAnalysisForm guide = new GuideEvaluateAnalysisForm();
            guide.MdiParent = this;
            guide.Show();
        }

        private void RestaurantEvaluateAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "RestaurantEvaluateAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            RestaurantEvaluateAnalysisForm restaurant = new RestaurantEvaluateAnalysisForm();
            restaurant.MdiParent = this;
            restaurant.Show();
        }

        private void VehicleEvaluateAnalysisBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "VehicleEvaluateAnalysisForm")
                {
                    form.Activate();
                    return;
                }
            }
            VehicleEvaluateAnalysisForm vehicle = new VehicleEvaluateAnalysisForm();
            vehicle.MdiParent = this;
            vehicle.Show();
        }

        private void ShopCommissionVerifyBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ShopCommissionVerifyForm")
                {
                    form.Activate();
                    return;
                }
            }
            CommissionScheduleVerifyForm shopCommission = new CommissionScheduleVerifyForm();
            shopCommission.MdiParent = this;
            shopCommission.Show();
        }

        private void commissionDetailistBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "CommissionDetailistForm")
                {
                    form.Activate();
                    return;
                }
            }
            CommissionDetailistForm ommissionDetail = new CommissionDetailistForm();
            ommissionDetail.MdiParent = this;
            ommissionDetail.Show();
        }

        private void ShopCommissionStatisticsBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "ShopCommissionStatisticsForm")
                {
                    form.Activate();
                    return;
                }
            }
            ShopCommissionStatisticsForm shopCommission = new ShopCommissionStatisticsForm();
            shopCommission.MdiParent = this;
            shopCommission.Show();
        }

        private void SalesCommissionStatisticsBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "SalesCommissionStatisticsForm")
                {
                    form.Activate();
                    return;
                }
            }
            SalesCommissionStatisticsForm salesCommission = new SalesCommissionStatisticsForm();
            salesCommission.MdiParent = this;
            salesCommission.Show();
        }

        private void GuideCommissionStatisticsBarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "GuideCommissionStatisticsForm")
                {
                    form.Activate();
                    return;
                }
            }
            GuideCommissionStatisticsForm guideCommission = new GuideCommissionStatisticsForm();
            guideCommission.MdiParent = this;
            guideCommission.Show();
        }
    }
}
